﻿@{
    ViewBag.Title = "Thống kê loại nguyên vật liệu";
}

<script type="text/javascript">
    $(document).ready(function () {
        $('#CheckValid').bootstrapValidator({
            message: 'This value is not valid',
            excluded: [':disabled'],
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                ProductModelID: {
                    validators: {
                        notEmpty: {
                            message: 'Phải chọn mẫu'
                        }
                    }
                },
            }
        }).on('success.form.bv', function (e) {
            // Prevent form submission
            e.preventDefault();

            // Get the form instance
            var $form = $(e.target);

            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            $("#EndDate").datepicker("option", "dateFormat", "mm/dd/yy");
            $("#StartDate").datepicker("option", "dateFormat", "mm/dd/yy");
            // Use Ajax to submit form data
            $.ajax({
                type: "POST",
                url: '@Url.Action("PrintView", "PrintMaterial")',
                async: false,
                cache: false,
                data: { ID: $("#ProductModelID").val() },
                success: function (result) {
                    $("#List").html(result);
                    $(".link").href.replace("1", $("#ProductModelID").val());
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(xhr.status);
                    alert(xhr.responseText);
                    alert(thrownError);
                }
            });
        });
    });
</script>
<div id="breadcrumb">
    <div class="container">
        <div id="con_top">
            <div class="c_container">
                <h3>Tổng hợp nguyên vật liệu theo mẫu sản phẩm</h3>
            </div>
        </div>
    </div>
</div>
<form class="form-horizontal" role="form" id="CheckValid" style="margin-top: 10px;">
    <div class="form-group">
        <label for="dtEfective" class="col-sm-3 control-label" style="margin-top:10px;">Chọn mẫu sản phẩm</label>
        <div class="col-sm-4" style="margin-top:10px;">
            <div>
                @*@Html.DropDownList("ProductModelID", new SelectList(ViewData["ProductModel"] as IEnumerable<Data.Models.ProductModel>, "ID", "Code"), "Chọn mẫu sản phẩm", new { @class = "form-control" })*@
                <select id="ProductModelID" name="ProductModelID" class="form-control">
                    <option value="0">Chọn mẫu sản phẩm</option>
                    @foreach (var item in ViewData["ProductModel"] as IEnumerable<Data.Models.ProductModel>)
                    { 
                        <option value="@item.ID">@item.Code - @item.Name</option>
                    }
                </select>

            </div>
            <div class="cleardiv"></div>
            <div class="btn-group">
                <button id="btnSaveSale" type="submit" class="btn btn-defaultxero">Xem báo cáo</button>
            </div>
            <div class="btn-group">
                <button id="btnCancelSale" type="button" onclick="javascript: location.href = '/PriceStore';" class="btn btn-defaultxero">Hủy</button>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div id="List" class="col-sm-8 col-sm-offset-3">
        </div>
    </div>

</form>
